<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script th:src="@{/webjars/jquery/3.5.1/jquery.min.js}"></script>
    <script th:inline="javascript">
        $(function () {
            $.getJSON('/mas',function (result) {
                let majorid = [[${teacher.majorid}]]
                $("[name=majorid]").append("<option value=''>请选择</option>")
                for (let ma of result){
                    if (ma.majorid == majorid){
                        $("[name=majorid]").append("<option selected value='" + ma.majorid + "'>" + ma.majorname + "</option>")
                    }else{
                        $("[name=majorid]").append("<option value='" + ma.majorid + "'>" + ma.majorname + "</option>")
                    }
                }
            })
        })
    </script>
</head>

<body>
<h1>修改</h1>
<form th:action="@{/teas/update}" method="post">
    <input type="hidden" name="tid" th:value="${teacher.tid}"/>
    <table>
        <tr>
            <td>majorid</td>
            <td>
                <select name="majorid"></select>
            </td>
        </tr>
        <tr>
            <td>tname</td>
            <td>
                <input name="tname" th:value="${teacher.tname}">
            </td>
        </tr>
        <tr>
            <td>hiredate</td>
            <td>
                <input name="hiredate" th:value="${#dates.format(teacher.hiredate,'yyyy-MM-dd')}"/>
            </td>
        </tr>
        <tr>
            <td>tsex</td>
            <td>
                <input name="tsex" th:value="${teacher.tsex}">
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <input type="submit" value="修改">
            </td>
        </tr>

    </table>
</form>

</body>
</html>